#include<bits/stdc++.h>
using namespace std;
#define int long long
#define double long double
const int maxn=1e5+10,maxl=1e6+10;
int T,n,m,l,v;
struct node{
    int in0,v0,a0;
}r[maxn];
struct edge{
    double ls,rs;
}r2[maxn],inp[maxn];
int p[maxl];
bool ba,bb,bc;
void solve(int nv,int ni)
{
    double x0=1.0*(v*v-nv*nv)/(r[ni].a0*2);
    if(nv>v)
        r2[ni].rs=max((double)l,r[ni].in0+x0);
    else
    {
        if(r[ni].in0+x0>=l)
            r2[ni].ls=r2[ni].rs=-1;
        else
            r2[ni].ls=r[ni].in0+x0,r2[ni].rs=l;
    }
    return;
}
signed main()
{
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    cin>>T;
    while(T--)
    {
        ba=true,bb=true,bc=true;
        cin>>n>>m>>l>>v;
        for(int i=1;i<=n;i++)
        {
            cin>>r[i].in0>>r[i].v0>>r[i].a0;
            if(r[i].a0<0)
            {
                ba=false;
                bb=false;
            }
            else if(r[i].a0>0)
            {
                ba=false;
                bc=false;
            }
            else
            {
                bb=false;
                bc=false;
            }
        }
        for(int i=1;i<=m;i++)
            cin>>p[i];
        for(int i=1;i<=n;i++)
        {
            if(r[i].a0==0)
            {
                if(r[i].v0>v)
                    r2[i].ls=r[i].in0,r2[i].rs=l;
                else
                    r2[i].ls=r2[i].rs=-1;
            }
            else if(r[i].a0<0)
            {
                if(r[i].v0<=v)
                    r2[i].ls=r2[i].rs=-1;
                else
                    r2[i].ls=r[i].in0,solve(r[i].v0,i);
            }
            else
            {
                if(r[i].v0>=v)
                    r2[i].ls=r[i].in0,r2[i].rs=l;
                else
                    solve(r[i].v0,i);
            }
        }
        int ans=0;
        for(int i=1;i<=n;i++)
            for(int j=1;j<=m;j++)
                if(ba)
                {
                    if(r2[i].ls<=p[j]&&r2[i].rs>=p[j])
                    {
                        ans++;
                        break;
                    }
                }
                else if(bb)
                {
                    if(r2[i].ls<p[j]&&r2[i].rs>=p[j])
                    {
                        ans++;
                        break;
                    }
                }
        cout<<ans<<' ';
        if(ba||bb)
        {
            if(ans!=0)
                cout<<m-1<<endl;
            else
                cout<<m<<endl;
            continue;
        }
    }
    return 0;
}
/*
1
5 5 15 3
0 3 0
12 4 0
1 1 4
5 5 ‐2
6 4 ‐4
2 5 8 9 15
*/
